﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Logic.Pathing;

namespace FelMaster.Dev
{
    public partial class TargetInfo : Form
    {
        private static TargetInfo instance = new TargetInfo();

        public static void Display()
        {
            if (instance == null || instance.IsDisposed)
                instance = new TargetInfo();
            if (!instance.Visible)
                instance.Show();
        }

        private TargetInfo()
        {
            InitializeComponent();
        }

        void timer1_Tick(object sender, EventArgs e)
        {
            var target = ObjectManager.Me.CurrentTarget;

            tname.Text = target == null ? "<No target>" : target.Name;
            tguid.Text = target == null ? "" : target.Guid.ToString();
            distance.Text = target == null ? "" : Math.Round(target.Distance, 3).ToString();
            realDistance.Text = target == null ? "" : Math.Round(SimCraftBase.Instance.DistanceToTargetBoundingBox(target), 3).ToString();
            
            if (target != null)
            {
                //facing
                var me = ObjectManager.Me.Location;
                var ta = target.Location;
                facing.Text = target == null ? "" : (Math.Round(SimCraftBase.Instance.FacingTowardsUnit_Degrees(me, ta), 2) + "°");
            }
        }
    }
}
